package com.wise.service.cms.content.successarticlecolumn;

import cn.hutool.core.bean.BeanUtil;
import com.wise.entities.content.ArticleColumn;
import com.wise.entities.content.SuccessArticle;
import com.wise.entities.content.SuccessArticleColumn;
import com.wise.framework.basic.DateTimeUtil;
import com.wise.framework.daomodel.DaoSave;
import com.wise.framework.session.CurrentUserId;
import com.wise.framework.session.GetAcceptLanguage;
import com.wise.summer.v1.cms.content.column.AddColumn;
import com.wise.summer.v1.cms.content.successcolumn.AddSuccessColumn;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

@Service
@SummerService
public class AddSuccessColumnColumnService implements SummerServiceBean<AddSuccessColumn> {
    @Override
    public void sum(AddSuccessColumn model) {
        String lang = GetAcceptLanguage.s(true);
        SuccessArticleColumn articleColumn = new SuccessArticleColumn();
        BeanUtil.copyProperties(model, articleColumn);
        articleColumn.setLang(lang);
        articleColumn.setAlias(model.getAlias());
		articleColumn.setCreatedBy(CurrentUserId.s(true));
		articleColumn.setCreationDate(DateTimeUtil.timestampNow());
        DaoSave.s(articleColumn);
        model.setSummerResult(articleColumn);
    }
}
